<template>
	<view class="content">

		<!-- 用户头像header -->
		<view class='member-top'>
			<image class='bg-img' src='/static/image/member-bg.png'></image>
			<view class='member-top-c'>
				<template v-if="hasLogin">
					<view><image class='user-head-img' mode="aspectFill" :src='userInfo.avatar'></image></view>
					<view style="margin-top: 8px;">
						<view class='user-name'>{{ userInfo.nickname }}</view>
						<view class="fz12 grade" v-if="userInfo.grade_name">
							{{userInfo.grade_name}}
						</view>
						<view class="fz12 integral">积分&nbsp;{{ pointList.length ? pointList[0].balance : 0}}</view>
					</view>
				</template>
				<template v-else>
					<!-- #ifdef H5 || APP-PLUS -->
					<image class='user-head-img' mode="aspectFill" :src='$store.state.config.shop_logo'></image>
					<view class="login-btn" @click="toLogin">
						登录/注册
					</view>
					<!-- #endif -->
					<!-- #ifdef MP-WEIXIN -->
					<view class="user-head-img">
						<open-data type="userAvatarUrl"></open-data>
					</view>
					<view>
						<button class="login-btn" hover-class="btn-hover" @click="goLogin()">授权登录</button>
					</view>
					<!-- #endif -->
					<!-- #ifdef MP-ALIPAY -->
					<view class="user-head-img"></view>
					<view>
						<button class="login-btn" open-type="getAuthorize" @click="getALICode" hover-class="btn-hover">授权登录</button>
					</view>
					<!-- #endif -->
					<!-- #ifdef MP-TOUTIAO -->
					<image class='user-head-img' mode="aspectFill" :src='$store.state.config.shop_logo'></image>
					<view class="login-btn" @click="goLogin()">
						登录/注册
					</view>
					<!-- #endif -->
				</template>

			</view>
		</view>
		<!-- 用户头像header end -->
		<!-- <button class='login-btn' open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" >微信一键登录</button> -->
		<!-- 订单列表信息 -->
		<view class='cell-group'>
			<view class='cell-item right-img' @click="orderNavigateHandle('../order/orderlist')">
				<view class='cell-item-hd'>
					<view class="img">
						<!-- <img class='cell-hd-icon'  :src="imageList['47adbc2a531d8edb088d5360ba4215d1']"/> -->
						<img class='cell-hd-icon'  :src="imageList['89a1ec3864b3119405906d85daaf886d']"/>
					</view>
					
					<view class='cell-hd-title'>我的订单</view>
				</view>
				<view class='cell-item-ft'>
					<!-- <image class='cell-ft-next icon' src='/static/image/right.png'></image> -->
					<img class='cell-ft-next icon'  :src="imageList['b2c041435f380405458bc74684c31372']"/>
				</view>
			</view>
		</view>

		<view class='member-grid'>
			<view class='member-item' v-for="(item, index) in orderItems" :key="index" @click="orderNavigateHandle('../order/orderlist', index + 1)">
				<view class="badge color-f" v-if="item.nums">{{ item.nums }}</view>
				<image class='member-item-icon' :src='item.icon'></image>
				<text class='member-item-text'>{{ item.name }}</text>
			</view>
			<view class='member-item' @click="goAfterSaleList">
				<view class="badge color-f" v-if="afterSaleNums != 0">{{afterSaleNums}}</view>
				<image class='member-item-icon' :src="imageList['69084d286892e0f02b2c94be5d91bc43']"></image>
				<text class='member-item-text'>退换货</text>
			</view>
		</view>
		<!-- 订单列表end -->


		<!-- 其他功能菜单 -->
		<!-- 列表样式 -->
		<view class="" v-if="list == 1">
			<view class='cell-group margin-cell-group right-img'>
				<view class='cell-item' v-for="(item, index) in utilityMenus" :key="index" v-if="!item.unshowItem">
					<view class='cell-item-hd' @click="navigateToHandle(item.router)">
						<image class='cell-hd-icon' :src='item.icon'></image>
						<view class='cell-hd-title'>{{ item.name }}</view>
					</view>
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
			</view>
			
			<view class='cell-group margin-cell-group right-img' v-if="isClerk">
				<view class='cell-item' v-for="(item, index) in clerk" :key="index">
					<view class='cell-item-hd' @click="navigateToHandle(item.router)">
						<image class='cell-hd-icon' :src='item.icon'></image>
						<view class='cell-hd-title'>{{ item.name }}</view>
					</view>
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
			</view>
			<view class='cell-group margin-cell-group right-img' v-if="order">
				<view class='cell-item' v-for="(item, index) in order" :key="index">
					<view class='cell-item-hd' @click="navigateToHandle(item.router)">
						<image class='cell-hd-icon' :src='item.icon'></image>
						<view class='cell-hd-title'>{{ item.name }}</view>
					</view>
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
				<!-- #ifdef H5 || APP-PLUS-NVUE || APP-PLUS -->
				<view class='cell-item'>
					<view class='cell-item-hd' @click="showChat()">
						<image class='cell-hd-icon' src='/static/image/me-ic-phone.png'></image>
						<view class='cell-hd-title'>联系客服</view>
					</view>
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
				<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
				<view class='cell-item'>
					<button class="cell-item-hd " hover-class="none" open-type="contact" bindcontact="showChat" :session-from="kefupara">
						<image src='/static/image/me-ic-phone.png' class='cell-hd-icon'></image>
						<view class='cell-hd-title'>联系客服</view>
					</button>
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
				<!-- #endif -->
				<!-- #ifdef MP-TOUTIAO -->
				<view class='cell-item'>
					<button class="cell-item-hd " hover-class="none" open-type="contact" bindcontact="showChat" :session-from="kefupara">
						<image src='/static/image/me-ic-phone.png' class='cell-hd-icon'></image>
						<view class='cell-hd-title'>联系客服</view>
					</button>
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
				<!-- #endif -->
				<!-- #ifdef MP-ALIPAY -->
				<view class='cell-item'>
					<contact-button icon="/static/image/kefu2.png" size="170rpx*76rpx" tnt-inst-id="WKPKUZXG" scene="SCE00040186"
					 class="cell-item-hd " hover-class="none" />
					<view class='cell-item-ft'>
						<image class='cell-ft-next icon' src='/static/image/right.png'></image>
					</view>
				</view>
				<!-- #endif -->
				
			</view>
			
		</view>
		
		<!-- 表格样式 -->
		<view class="margin-cell-group" v-else>
			<view class="sale-block bgf">
				<view class="sale-title">
					<view class="img"  >
						<!-- <image class='cell-hd-icon' style="float: left; " :src="imageList['5617afecd130bab0a12adf7271f4c939']"></image> -->
						<img class='cell-hd-icon' style="float: left;" :src="imageList['f7f38694dd38698e90d856229d9688cb']" alt="">
					</view>
					
					<view class="text" style="margin-left: 20upx;">
						我的服务
					</view>
				</view>
				<view class="flc sale-list">
					<view class="item tc" v-for="(item,i) in utilityMenus" :key="i" v-if="(!item.unshowItem && i != 'invoice') || (!item.unshowItem && i == 'invoice' && invoice_switch == 1)">
						<view class="" @click="navigateToHandle(item.router)">
								<image class='cell-hd-icon' :src='item.icon'></image>
							<view class="text">
								<view class="badge color-f coupon" v-if="item.nums">{{ item.nums }}</view>
								<text class="">{{item.name}}</text>
							</view>
						</view>
					</view>

					<view class="item tc">
						<view class=""  @click="showModal=true">
								<image class='cell-hd-icon'  :src="imageList['6c7e632c9610efec4c001a644863790d']"></image>
							<view class="text">
								<text class="">兑换流程</text>
							</view>
						</view>
					</view>
					
					<view class="item tc" v-if="userInfo.grade == 10">
						<view class="" @click="goToShop" >
								<image class='cell-hd-icon'  :src="imageList['ea40c36ed7264cabc22985848df6fdff']"></image>
							<view class="text">
								<text class="">内部商店</text>
							</view>
						</view>
					</view>

					<view class="mask " v-if="showModal">
						<view class="pop">
							<view class="main">
								<ul class="nav">
									<li v-for="(item,index) in navListNew" :class = "{active:!(index-menuIndex)}" @click = 'menuShow(index)'> {{item.title}} </li>
								</ul>
								
								<view class="particulars">
									<view v-for="(data,index2) in navListNew" v-show = 'menuIndex == (index2)'>
										<h4>{{data.title}}</h4>
										<view class="title grade-tit">
											<jshopContent :content="data.content" :is_all_show="1"  v-if="data.content"></jshopContent>
										
										</view>
									</view>


								</view>

								<view class="shut"  @click="showModal=false">
									<img  :src="imageList['74c0714ebaaf55638fdc00172e2d6417']" alt="">
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="sale-block bgf" v-if="store_switch && isClerk">
				<view class="sale-title">
					<image class='cell-hd-icon' src='/static/image/shop.png'></image>
					<view class="">
						门店管理
					</view>
				</view>
				<view class="flc sale-list">
					<view class="item tc" v-for="(item,i) in clerk" :key="i">
						<view class="" @click="navigateToHandle(item.router)">
							<view class="">
								<image class='cell-hd-icon' :src='item.icon'></image>
							</view>
							<view class="text">
								<text class="">{{item.name}}</text>
							</view>
						</view>
					</view>
				</view>
			</view> -->
			<view class="sale-block bgf">
				<view class="sale-title">
					<view class="img">
						<image class='cell-hd-icon' style="float:left" :src="imageList['abc1fbf1f191e230b65975fe49bbe04c']"></image>
						<!-- <img lass='cell-hd-icon' style="float:left"  :src="imageList['abc1fbf1f191e230b65975fe49bbe04c']" alt=""> -->
					</view>
					
					<view class="" style="margin-left: 10px;">
						其他
					</view>
				</view>
				<view class="flc sale-list">
                    <!-- 微信小程序消息订阅 -->
                    <!-- #ifdef MP-WEIXIN -->
                    <!-- <view class="item tc" v-if="isTip">
                    	<view class="" @click="navigateToHandle('../setting/subscription/index')">
                    		<view class="">
                    			<image  :src="imageList['8776eee5a08f64cde88308ae8057aaf8']" class='cell-hd-icon'></image>
                    		</view>
                    		<view class="text">
                    			<text class="">消息订阅</text>
                    		</view>
                    	</view>
                    </view> -->
                    <!-- #endif -->
					<view class="item tc" v-for="(item,i) in order" :key="i" v-if="!item.unshowItem">
						<view class="" @click="navigateToHandle(item.router)">
							<view class="">
								<image class='cell-hd-icon' :src='item.icon'></image>
							</view>
							<view class="text">
								<text class="">{{item.name}}</text>
							</view>
						</view>
					</view>
					<!-- #ifdef H5 || APP-PLUS || APP-PLUS-NVUE -->
					<view class="item tc">
						<view @click="showChat">
							<view class="">
								<image  :src="imageList['8776eee5a08f64cde88308ae8057aaf8']" class='cell-hd-icon'></image>
							</view>
							<view class="text">
								<text class="">联系客服</text>
							</view>
						</view>
					</view>
					<!-- #endif -->
					<view class="item tc" v-if="userInfo.grade == 10">
						<view class="" @click="daiFinish()">
							<view class="">
								<!-- <image class='cell-hd-icon' src='/static/image/subscription.png'></image> -->
								<img class='cell-hd-icon' :src="imageList['65933732ab2402432163ec1f0255e553']" alt="">
							</view>
							<view class="text">
								<text class="">带看完成二维码</text>
							</view>
						</view>
					</view>
					
					<view class="item tc" v-if="userInfo.grade == 10">
						<view class="" @click="allFinish()">
							<view class="">
								<img class='cell-hd-icon' :src="imageList['58330c695cb1861a3af5ea17e8522abe']" alt="">
							</view>
							<view class="text">
								<text class="">成交二维码</text>
							</view>
						</view>
					</view>
					<!-- 评论领礼品 -->
					<view class="item tc" v-if="userInfo.prize == 1">
						<view class="" @click="getPrize()">
							<view class="">
								<img class='cell-hd-icon' :src="imageList['2b4d08e8c98c64be9a14a7529bfaa5ce']" alt="">
							</view>
							<view class="text">
								<text class="">评论领礼品</text>
							</view>
						</view>
					</view>
					
					
				</view>
			</view>
		</view>
		<tabBar  :index_p2="index_p2" ></tabBar>	
		<!-- 其他功能菜单end -->
		<!-- <jihaiCopyright></jihaiCopyright> -->
	</view>
</template>


<script>
	import jihaiCopyright from '@/components/jihai-copyright/jihaiCopyright.vue'
	import tabBar from '@/components/tabBar/tabBar.vue'
	import jshopContent from '@/components/jshop/jshop-content.vue' //视频和文本解析组件
	import {
		checkLogin
	} from '@/config/mixins.js'
	export default {
		components: {
			jihaiCopyright,
			tabBar,
			jshopContent
		},
		mixins: [checkLogin],
		data() {
			return {
				menuIndex:0,
        		navList:['积分规则','会员中心','服务中心','售后服务','联系我们','联系客服'],
				navListNew:[],
				showModal: false,
				pointList: [], // 积分记录
				open_id: '',
				hasLogin: false,
				userInfo: {}, // 用户信息
				kefupara: '', //客服传递资料
				afterSaleNums: 0,
				isClerk: false,
				alipayNoLogin: true,
				alipayName: '',
				alipayAvatar: '',
				config:'',//配置信息
				orderItems: [{
						name: '待付款',
						icon: '/static/image/me-ic-obligation.png',
						nums: 0
					},
					{
						name: '待发货',
						icon: '/static/image/me-ic-sendout.png',
						nums: 0
					},
					{
						name: '待收货',
						icon: '/static/image/me-ic-receiving.png',
						nums: 0
					},
					{
						name: '待评价',
						icon: '/static/image/me-ic-evaluate.png',
						nums: 0
					}
				],
				utilityMenus: {
					distribution: {
						name: '分销中心',
						icon: '/static/image/distribution.png',
						router: '../distribution/user',
						unshowItem: false
					},
					coupon: {
						name: '我的优惠券',
						icon: '/static/image/ic-me-coupon.png',
						router: '../coupon/index',
						unshowItem: false,
						nums:0
					},
					// balance: {
					// 	name: '我的余额',
					// 	icon: '/static/image/ic-me-balance.png',
					// 	router: '../balance/index',
					// 	unshowItem: false
					// },
					// invoice: {
					// 	name: '我的发票',
					// 	icon: '/static/image/ic-me-invoice.png',
					// 	router: '../invoice/index',
					// 	unshowItem: false
					// },
					integral: {
						name: '我的积分',
						icon: '/static/image/integral.png',
						router: '../integral/index',
						unshowItem: false
					},
					address: {
						name: '地址管理',
						icon: '/static/image/me-ic-site.png',
						router: '../address/list',
						unshowItem: false
					},
					collection: {
						name: '我的收藏',
						icon: '/static/image/ic-me-collect.png',
						router: '../collection/index',
						unshowItem: false
					},
					history: {
						name: '我的足迹',
						icon: '/static/image/ic-me-track.png',
						router: '../history/index',
						unshowItem: false
					},
					// flow: {
					// 	name: '兑换流程',
					// 	icon: '',
					// }
					
				},
				clerk: [{
						name: '提货单列表',
						icon: '/static/image/ic-me-take.png',
						router: '../take_delivery/list'

					},
					{
						name: '提货单核销',
						icon: '/static/image/me-ic-about.png',
						router: '../take_delivery/index'
					}
				],
				order: {
					// bargain: {
					// 	name: '砍价记录',
					// 	icon: '/static/image/me-ic-sendout.png',
					// 	router: '../bargain/list',
					// 	unshowItem: false
					// },
					// subscription: {
					// 	name: '消息订阅',
					// 	icon: '',
					// 	router: '../setting/subscription/index',
					// },
					invite: {
						name: '邀请好友',
						icon: '',
						router: '../invite/index',
						unshowItem: true
					},
					setting: {
						name: '系统设置',
						icon: '/static/image/me-ic-set.png',
						router: '../setting/index',
						unshowItem: false
					}
				},
				list: 2,
				suTipStatus: false,
				
				imageList:[],
				index_p2:3,
				index_path:'/pages/member/index/index'
			}
		},
		onLoad(){
			// uni.showTabBar();
			this.userPointLog()
		},
		onShow() {
			this.initData();
			
			this.$api.ExchangeProcess({
				
			}, (res)=>{
				this.navListNew = res.data
				console.log(res.data);
			})
			// console.log(this.userInfo);
			
		},
		methods: {
			// 积分
			userPointLog () {
				let _this = this
				let data = {
					page: _this.page,
					limit: _this.limit
				}
				
				_this.loadStatus = 'loading'
				
				_this.$api.pointLog(data, function (res) {
					if (res.status) {
						_this.pointList = [..._this.pointList, ...res.data]
						// 判断数据是否加载完毕
						if (res.count > _this.pointList.length) {
							_this.page ++
							_this.loadStatus = 'more'
						} else {
							_this.loadStatus = 'noMore'
						}
					} else {
						// 接口請求出錯
						_this.$common.errorToShow(res.msg)
						_this.loadStatus = 'more'
					}
				})
			},
			
			getPhoneNumber:function(e){
				var _this = this;
				var encryptedData = e.detail.encryptedData;
				var iv = e.detail.iv;
				
				uni.login({
					provider:'weixin',
					success:(res)=>{
						var code = res.code;
						_this.$api.getSessionKey({
							'encryptedData':encryptedData,
							'iv':iv,
							'code':code
						}, (res)=>{
							console.log(res);
						})
					}
				})
			},
			
			goToShop(){
				this.$common.navigateTo('/pages/classify/index?id=999');
			},
			menuShow (index) {
				this.menuIndex = index
				console.log(this.menuIndex)
	 		},
	 
			checkMobile(mobile){
			    return RegExp(/^1[345789]\d{9}$/).test(mobile);
			},
			// 评论领礼品
			getPrize(){
				let data = {}
				let userToken = this.$db.get('userToken')
				if (userToken) {
				    data.token = userToken
				}
				
				if(this.checkMobile(this.userInfo['mobile'])== false){
					// console.log('手机号错误');
					this.$common.errorToShow('手机号错误')
					return false;
				}
				data.mobile = this.userInfo['mobile'];
				let _this = this;
				this.$api.getPrize(data, res => {
					// console.log(res);
					if (res.status) {
						this.$common.navigateTo('/pages/share?poster=' + encodeURIComponent(res.data))
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
				
			},
			daiFinish(){
				uni.navigateTo({
					url:'/pages/member/invite/index2'
				})
				
				/* let data = {}
				let userToken = this.$db.get('userToken')
				if (userToken) {
				    data.token = userToken
				}
				let _this = this;
				this.$api.daiFinish(data, res => {
					console.log(res);
					if (res.status) {
						this.$common.navigateTo('/pages/share?poster=' + encodeURIComponent(res.data))
					} else {
						this.$common.errorToShow(res.msg)
					}
				}) */
				
			},
			//成交二维码
			allFinish(){
				uni.navigateTo({
					url:'/pages/member/invite/index3'
				})
			},
			
			goLogin(){
				uni.navigateTo({
					url:'/pages/login/choose/index'
				})
			},
			getUserInfo(e) {
				let _this = this
				//return false;
				if (e.detail.errMsg == 'getUserInfo:fail auth deny') {
					_this.$common.errorToShow('未授权')
				} else {
					var data = {
						open_id: _this.open_id,
						iv: e.detail.iv,
						edata: e.detail.encryptedData,
						signature: e.detail.signature
					}
					//有推荐码的话，带上
					var invitecode = _this.$db.get('invitecode')
					if (invitecode) {
						data.invitecode = invitecode
					}
					_this.toWxLogin(data)
				}
			},
			getALICode() {
				let that = this
				uni.login({
					scopes: 'auth_user',
					success: (res) => {
						if (res.authCode) {
							uni.getUserInfo({
								provider: 'alipay',
								success: function(infoRes) {
									if (infoRes.errMsg == "getUserInfo:ok") {
										let user_info = {
											'nickname': infoRes.nickName,
											'avatar': infoRes.avatar
										}
										that.aLiLoginStep1(res.authCode, user_info);
									}
								},
								fail: function(errorRes) {
									this.$common.errorToShow('未取得用户昵称头像信息');
								}
							});
						} else {
							this.$common.errorToShow('未取得code');
						}
					},
					fail: function(res) {
						this.$common.errorToShow('用户授权失败my.login');
					}
				});
			},
			getWxCode() {
				let that = this
				uni.login({
					scopes: 'auth_user',
					success: function(res) {
					// console.log(res.code)
						if (res.code) {
							that.wxLoginStep1(res.code)
							
						} else {
							this.$common.errorToShow('未取得code')
						}
					},
					fail: function(res) {
						this.$common.errorToShow('用户授权失败wx.login')
					}
				})
			},
			wxLoginStep1(code) {
				// console.log(3)
				this.$api.login1({
					code
				}, res => {
					// console.log(res)

					if (res.status) {
						this.open_id = res.data
					} else {
						this.$common.errorToShow(res.msg, function() {
							uni.navigateBack({
								delta: 1
							})
						})
					}
				})
			},
			aLiLoginStep1(code, user_info) {
				let data = {
					'code': code,
					'user_info': user_info
				}
				this.$api.alilogin1(data, res => {
					this.alipayNoLogin = false;
					if (res.status) {
						this.open_id = res.data.user_wx_id
						//判断是否返回了token，如果没有，就说明没有绑定账号，跳转到绑定页面
						if (!res.data.hasOwnProperty('token')) {
							this.$common.redirectTo('/pages/login/login/index?user_wx_id=' + res.data.user_wx_id);
						} else {
							this.$db.set('userToken', res.data.token)
							this.initData()
						}
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			},
			toWxLogin(data) {
				let _this = this
				_this.$api.login2(data, function(res) {
					if (res.status) {
						//判断是否返回了token，如果没有，就说明没有绑定账号，跳转到绑定页面
						if (typeof res.data.token == 'undefined') {
							uni.redirectTo({
								url: '/pages/login/login/index?user_wx_id=' + res.data.user_wx_id
							})
						} else {
							_this.$db.set('userToken', res.data.token)
							_this.initData()
						}
					} else {
						_this.$common.errorToShow('登录失败，请重试')
					}
				})
			},
			toLogin() {
				this.$common.navigateTo("/pages/login/login/index1")
			},
			initData() {
				// 获取用户信息
				var _this = this
				//判断是开启分销还是原始推广
				this.$api.shopConfig(res => {
					this.config = res;
					if (res.open_distribution) {
						this.order.invite.unshowItem = true
					} else {
						this.utilityMenus.distribution.unshowItem = true
						this.order.invite.unshowItem = false
					}
				})
				if (this.$db.get('userToken')) {
					this.hasLogin = true
					this.$api.userInfo({}, res => {
						if (res.status) {
							_this.userInfo = res.data
							// console.log(_this.userInfo);
							// #ifdef MP-WEIXIN
							//微信小程序打开客服时，传递用户信息
							var kefupara = {}
							kefupara.nickName = res.data.nickname
							kefupara.tel = res.data.mobile
							_this.kefupara = JSON.stringify(kefupara)
							// #endif
							// 获取订单不同状态的数量
							let data = {
								ids: '1,2,3,4',
								isAfterSale: true
							}
							_this.$api.getOrderStatusSum(data, res => {
								if (res.status) {
									_this.orderItems.forEach((item, key) => {
										item.nums = res.data[key + 1]
									})
									_this.afterSaleNums = res.data.isAfterSale ?
										res.data.isAfterSale :
										0
								}
								// console.log(res);
								this.utilityMenus.coupon.nums=res.data.coupon
							})
							//判断是否是店员
							this.$api.isStoreUser({}, res => {
								this.isClerk = res.flag
							})
						}
					})
				} else {
					// console.log(2)
					this.hasLogin = false
					// #ifdef MP-WEIXIN
					this.getWxCode()

					// #endif
				}
                
                this.userIsSubscription();
				
				//获取图片
				this.$api.getImage({
						ids: 'ea40c36ed7264cabc22985848df6fdff,abc1fbf1f191e230b65975fe49bbe04c,f7f38694dd38698e90d856229d9688cb,89a1ec3864b3119405906d85daaf886d,74c0714ebaaf55638fdc00172e2d6417,2b4d08e8c98c64be9a14a7529bfaa5ce,6c7e632c9610efec4c001a644863790d,58330c695cb1861a3af5ea17e8522abe,69084d286892e0f02b2c94be5d91bc43,d452a980d59177dcb6575d331b966605,65933732ab2402432163ec1f0255e553,f6ed1ecb73502126ce278c5b7ead33fd,47adbc2a531d8edb088d5360ba4215d1,b2c041435f380405458bc74684c31372,0e9f1939c24a3999ff3a6a2d54917c25,a4763ef75adbc19228db253e127e4dbf,73c54cd5ac32636287f28d76a9cae03a,c5a0b53b8530a0925cbc64698b7c5013,e911920ae5c562e4bc016412d99dc29b,5617afecd130bab0a12adf7271f4c939,03c8d1c84a9e9177b8b3b351f8c8895a,8776eee5a08f64cde88308ae8057aaf8,13d2f5321ce965072ce377110f5bc126,f77de61d527aaeae788f862e0eecc9f4,149d7059a448af2e462957eda81e8108,b52be40e305658f7e7618826ade1fd4b,cffdfce33b0963d634cc6a9b77ae1771,0761fb8089a31d1ca1660ae128c0310b,17530178bc588cc5799ee1da007a5c1a'
					},
					res => {
						// console.log()
						this.orderItems[0].icon=res['0e9f1939c24a3999ff3a6a2d54917c25'];
						this.orderItems[1].icon=res['73c54cd5ac32636287f28d76a9cae03a'];
						this.orderItems[2].icon=res['c5a0b53b8530a0925cbc64698b7c5013'];
						this.orderItems[3].icon=res['a4763ef75adbc19228db253e127e4dbf'];
						
						this.utilityMenus.distribution.icon=res['149d7059a448af2e462957eda81e8108'];
						this.utilityMenus.coupon.icon=res['e911920ae5c562e4bc016412d99dc29b'];
						// this.utilityMenus.balance.icon=res['f77de61d527aaeae788f862e0eecc9f4'];	
						// this.utilityMenus.invoice.icon=res['17530178bc588cc5799ee1da007a5c1a'];
				
						this.utilityMenus.integral.icon=res['149d7059a448af2e462957eda81e8108'];
						this.utilityMenus.address.icon=res['b52be40e305658f7e7618826ade1fd4b'];
						this.utilityMenus.collection.icon=res['cffdfce33b0963d634cc6a9b77ae1771'];
						this.utilityMenus.history.icon=res['0761fb8089a31d1ca1660ae128c0310b'];
						//this.utilityMenus.flow.icon=res['6c7e632c9610efec4c001a644863790d'];


						this.order.invite.icon=res['f6ed1ecb73502126ce278c5b7ead33fd'];
						this.order.setting.icon=res['13d2f5321ce965072ce377110f5bc126'];
						
						// this.order.subscription.icon=res['d452a980d59177dcb6575d331b966605'];
						
						this.imageList = res;
					},
					// msg => {
					// 	this.utilityMenus[0].icon=msg['a4763ef75adbc19228db253e127e4dbf'];
					// 	this.imageList = res;
					// }
				
					);
			},
			navigateToHandle(pageUrl) {
				if (!this.hasLogin) {
					return this.checkIsLogin()
				}
				this.$common.navigateTo(pageUrl)
			},
			orderNavigateHandle(url, tab = 0) {
				if (!this.hasLogin) {
					return this.checkIsLogin()
				}
				this.$store.commit('orderTab', tab)
				this.$common.navigateTo(url)
			},
			goAfterSaleList() {
				if (!this.hasLogin) {
					return this.checkIsLogin()
				}
				this.$common.navigateTo("/pages/member/after_sale/list")
			},
			//在线客服,只有手机号的，请自己替换为手机号
			showChat() {
				// #ifdef H5
				let _this = this
				window._AIHECONG('ini', {
					entId: this.config.ent_id,
					button: false,
					appearance: {
						panelMobile: {
							tone: '#FF7159',
							sideMargin: 30,
							ratio: 'part',
							headHeight: 50
						}
					}
				})
				//传递客户信息
				window._AIHECONG('customer', {
					head: _this.userInfo.avatar,
					'名称': _this.userInfo.nickname,
					'手机': _this.userInfo.mobile
				})
				window._AIHECONG('showChat')
				// #endif

				// 打开客服页面
				// #ifdef APP-PLUS || APP-PLUS-NVUE
				this.$common.navigateTo('/pages/member/customer_service/index');
				// #endif
				
				// 头条系客服
				// #ifdef MP-TOUTIAO
				if(this.shopMobile != 0){
					let _this = this;
					tt.makePhoneCall({
						phoneNumber: this.shopMobile.toString(),
						success(res) {},
						fail(res) {}
					});
				}else{
					_this.$common.errorToShow('暂无设置客服电话');
				}
				// #endif
			},
			// toPages(url) {
			// 	console.log(url)
			// 	let userToken = this.$db.get('userToken')
			// 	if (!userToken) {
			// 		common.jumpToLogin()
			// 		return false
			// 	} else {
			// 		this.$common.navigateTo(url)

			// 	}
			// },
            //查询用户订阅
            userIsSubscription() {
                let userToken = this.$db.get("userToken");
                if (userToken && userToken != '') {
                	this.$api.subscriptionIsTip(res => {
                        if (res.status) { 
                            if (res.switch) {
                                this.suTipStatus = true;
                            } else {
                                this.suTipStatus = false;
                            }
                        } else {
                            this.suTipStatus = true;
                        }
                	});
                } else {
                    this.suTipStatus = true;
                }
			},
			
		
	},
		computed: {
			// 获取店铺联系人手机号
			shopMobile(){
				return this.$store.state.config.shop_mobile || 0;
			},
			invoice_switch() {
				return this.$store.state.config.invoice_switch || 2;
			},
			store_switch() {
				return this.$store.state.config.store_switch || 0;
			},
            isTip() {
                return this.suTipStatus;
            }
		},
		watch: {}
	}
</script>

<style lang="scss" scoped>
	*{
		margin: 0;
		padding: 0;
	}
	li{
		list-style: none;
	}
	.member-top {
		position: relative;
		width: 100%;
		height: 340upx;

	}

	.bg-img {
		position: absolute;
		width: 100%;
		height: 100%;
	}

	.member-top-c {
		position: absolute;
		top: 50%;
		left: 30%;
		transform: translate(-50%, -50%);
		text-align: center;
		display: flex;
	}

	.user-head-img {
		display: block;
		width: 160upx;
		height: 160upx;
		border-radius: 50%;
		overflow: hidden;
		background-color: rgba(255, 255, 255, 0.7);
		margin: 0 auto 16upx;
	}

	.user-name {
		font-size: 30upx;
		color: #fff;
		margin-bottom: 16upx;
		padding-left: 20px;
		text-align: left;
	}

	.grade {
		color: #FFF;
		padding-left: 20px;
		text-align: left;
		margin-bottom: 16upx;
	}
	.integral{
		color: #FFF;
		padding-left: 20px;
		text-align: left;
		font-size: 16px;
	}
	.member-grid {
		background-color: #fff;
		border-top: 2upx solid #eee;
		padding: 20upx 0;
	}
	.member-grid .member-item .member-item-icon{
		margin: 0 auto;
		padding-bottom: 10upx;
	}
	.margin-cell-group {
		margin: 20upx 0 120upx 0;
		color: #666666;
	}

	.badge {
		left: 80upx;
		top: -6upx;
	}

	button.cell-item-hd {
		background-color: #fff;
		padding: 0;
		line-height: 1.4;
		color: #333;
	}

	button.cell-item-hd:after {
		border: none;
	}

	.cell-item-hd{
		left: 20upx;
	}

	.cell-item-hd .img{
		margin-right: 20upx;
	}

	.login-btn {
		color: #FA531C;
		width: 180upx;
		height: 50upx;
		line-height: 50upx;
		border-radius: 25upx;
		background: #fff;
		font-size: 12px;
	}
	
	.sale-block {
		padding: 0 20upx;
		margin-bottom: 20upx;
		.sale-title {
			height: 72rpx;
			line-height: 72rpx;
			border-bottom: 2rpx solid #f0f0f0;
			display: flex;
			align-items: center;
			.img{
				.iconfont {
					padding-top: 8upx;
					margin-right: 12upx;
					color: $theme-color;
				}
			}	
		}

		.sale-list {
			display: flex;
			justify-content: flex-start;
			flex-wrap: wrap;

			.item {
				width: 25%;
				padding: 20upx 0;
				.iconfont {
					font-size: 40upx;
					color: #5e5e5e;
				}

				.text {
					// margin-top: 12upx;
					color: #4d4d4d;
					font-size: 24rpx;
					position: relative;
				}
			}
			.tc {
			    text-align: center;
				.cell-hd-icon{
					
					float: none;
					width: 60rpx;
					height: 60rpx;
					margin: 0;
				}
			}
		}
	}
	.coupon{
		top: -80rpx;
		left: 100rpx;
	}


// 兑换流程
	.active{
		line-height: 50upx;
		// width: 100%;
		border-radius: 5upx;
		background: #13c3c3;
		color: #fff;
	}
	.mask {
		width: 100%;
		height: 100%;
		background: rgba(51,51,51,0.5);
		position: fixed;
		top: 0;
		left: 0;	
		z-index: 999;
	}
	.mask .pop .main .shut{
		height: 30upx;
		width: 30upx;
		position: relative;		
		top: 20upx;
		right: 10upx;
	}
	.mask .pop .main .shut>img{
		height: 100%;
		width: 100%;
		
	}
	.mask .pop {
		width: 80%;
		height: 815upx;
		top: 50%;
        left: 50%;
		border-radius: 10upx;
		position: absolute;
		transform: translate(-50%, -50%);
        background: #fff;
		z-index: 1000;
	}
	.mask .pop .main{
		display: flex;
		// overflow: hidden;
	}
	.mask .pop .main .nav{
		height: 765upx;
		width: 200upx;
		text-align: center;
		padding-top: 50upx;
		// padding-bottom: 50upx;
		background: #89dab8;
	}
	.mask .pop .main .nav li{
		line-height: 50upx;
		margin: 20upx;
	}
	.mask .pop .main .particulars{
		width: 65%;
		height: 715upx;
		margin-top: 50upx;
		// padding-bottom: 50upx;
		overflow:scroll;
	}
	.mask .pop .main .particulars h4{
		text-align: center;
		margin-top: 30upx;
		letter-spacing: 2upx;
	}
	.mask .pop .main .particulars .title{
		letter-spacing: 3upx;
		margin-top: 20upx;
		margin-left: 20upx;
	}
	.mask .pop .main .particulars .title h5{
		font-size:32upx;
		margin-bottom: 10upx;
	}
</style>
